<?php

class Ads_Model_Rentsetting {

    private $_dbtable;

    public function __construct() {
        $this->_dbtable = new Ads_Model_DbTable_Rentsetting();
    }

    public function fetchAll() {
        $select = $this->_dbtable->select();
        return $this->_dbtable->fetchAll($select);
    }

    public function getRentSettingById($id) {
        $select = $this->_dbtable->select();
        $select->where('sr = ?', $id);
        return $this->_dbtable->fetchAll($select);
    }

    public function getRentSettingByName($name) {
        $select = $this->_dbtable->select();
        $select->where('name = ? ', $name);
        return $this->_dbtable->fetchAll($select);
    }

    public function getVacantTypeJSON() {
        $result = $this->getRentSettingByName("vacant_type");
        return $result[0]['details'];
    }

    public function getVacantTypeArray() {
        return json_decode($this->getVacantTypeJSON());
    }

    public function getPropertyTypeJSON() {
        $result = $this->getRentSettingByName("property_type");
        return $result[0]['details'];
    }

    public function getProprertyTypeArray() {
        return json_decode($this->getPropertyTypeJSON());
    }

    public function getRentalPeriodJSON() {
        $result = $this->getRentSettingByName("rental_period");
        return $result[0]['details'];
    }

    public function getRentalPeriodArray() {
        return json_decode($this->getRentalPeriodJSON());
    }

    public function getDepositeTypeJSON() {
        $result = $this->getRentSettingByName("deposite_type");
        return $result[0]['details'];
    }

    public function getDepositeTypeArray() {
        return json_decode($this->getDepositeTypeJSON());
    }

    public function getPrepaidRentTypeJSON() {
        return $this->getRentSettingByName("deposite_type");
    }

    public function getFurnishTypeJSON() {
        $result = $this->getRentSettingByName('furnish_type');
        return $result[0]['details'];
    }

    public function getFurnishTypeArray() {
        return json_decode($this->getFurnishTypeJSON());
    }

    public function getPrerentTypeJson() {
        $result = $this->getDepositeTypeJSON();
        return $result;
    }

    public function getPrerentTypeArray() {
        $result = $this->getDepositeTypeArray();
        return $result;
    }

    public function getPetsTypeJson() {
        $result = $this->getRentSettingByName('pets');
        return $result[0]['details'];
    }

    public function getPetsTypeArray() {
        return json_decode($this->getPetsTypeJson());
    }

}